package org.example.shop.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Configuration
@RestControllerAdvice
public class ExceptionConfig {

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public ApiResponse handleRuntimesException(RuntimeException e) {
        ApiResponse response = new ApiResponse();
        response.setCode(500);
        response.setMessage(e.getMessage());
        return response;
    }
}
